import sys
import os
import streamlit as st
from pathlib import Path

# 添加项目根目录到Python路径
sys.path.append(str(Path(__file__).parent.parent))

# 导入自定义模块
from app.auth import login_form
from app.forms import stock_in_form, stock_out_form
from app.database import init_db

# 初始化数据库
init_db()

# 登录验证
if "logged_in" not in st.session_state:
    st.session_state.logged_in = False

if not st.session_state.logged_in:
    login_form()
    st.stop()

# 主界面
st.title("📦 光明物资仓库管理系统")
menu = st.sidebar.selectbox("功能导航", ["入库管理", "出库管理"])
if menu == "入库管理":
    stock_in_form()
elif menu == "出库管理":
    stock_out_form()